<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
    <style>
        .fade-enter-active, .fade-leave-active{
            transition: opacity .5s ease;
        }
        .fade-enter, .fade-leave-to{
            opacity: 0;
        }
    </style>
</head>
<body>
    <template id="example2">
         <span>我是注册组件</span>
    </template>
    <template id="example1">
        <span>我是登录组件</span>
   </template>
    <div id="app">
        <a href="javascript:;" @click="componentName='example1'">登录</a>
        <a href="javascript:;" @click="componentName='example2'">注册</a>
        <transition name="fade" mode="in-out">
            <component v-bind:is="componentName"></component>
        </transition>
    </div>
    <script src="vue.js"></script>
    <script>
        Vue.component('example1',{template:'#example1'});
        Vue.component('example2',{template:'#example2'});
        var vm = new Vue({
           el:'#app',
           data:{
               componentName:''
           }
        })
    </script>
</body>
</html> 